
/**************************************TRIM IN JAVASCRIPT STARTS FROM HERE************************************************/
// Removes leading whitespaces
function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}


function Trim(str)
{  while(str.charAt(0) == (" ") )
  {  str = str.substring(1);
  }
  while(str.charAt(str.length-1) == " " )
  {  str = str.substring(0,str.length-1);
  }
  return str;
}

/************************************************TRIM IN JAVASCRIPT ENDS HERE*******************************************/

function regformvalidation()
{
	//alert("sadhashdlaskdlask");
	var NameVAlidation=/[0-9\*\=\_\>\<\:\@\&\%\?\$\-\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\+\#\\]/;
	//var USERNameVAlidation=/[\*\=\_\>\<\:\@\&\%\?\$\-\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\+\#\\]/;
	var EmailVALIdation=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var PhonEVAlidation=/[a-zA-Z\*\=\_\>\<\:\@\&\%\?\$\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\\]/;
	var AddressvalIDAtiON=/[\*\=\_\>\<\:\@\&\%\?\$\!\^\(\)\{\}\|\~\`\"\;\.\+\#\\]/;
	var ZIpVAlidation=/[\*\=\_\>\<\:\@\&\%\?\$\-\/\!\^\(\)\{\}\|\~\`\'\"\;\,\.\+\#\\]/;
	var RETURnvalUE=false;

	if(document.getElementById("UserName") != null)
	{
		
		if(document.getElementById("UserName").value != '')
		{
			if(document.getElementById("UserName").value.length < 6)
			{
				document.getElementById("UserNameError").innerHTML="<br>Please Type Your User Name Greater Than 6 characters.";
				document.getElementById("UserNameError").style.display='';
				document.getElementById("UserName").ClassName="RedClass";
				document.getElementById("UserName").focus();
				return false;
			}
	var str =Trim(document.getElementById("UserName").value);

			if( str=='')
			{
				document.getElementById("UserNameError").innerHTML="<br>Please Dont Give Space In User Name Field.";
				document.getElementById("UserNameError").style.display='';
				document.getElementById("UserName").ClassName="RedClass";
				document.getElementById("UserName").value="";
				document.getElementById("UserName").focus();
				return false;
			}
			else
			{
				document.getElementById("UserNameError").innerHTML="";
				document.getElementById("UserNameError").style.display='none';
				document.getElementById("UserName").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("UserNameError") != null)
			{
				document.getElementById("UserNameError").innerHTML="<br>Please Type Your User Name.";
				document.getElementById("UserNameError").style.display='';
				document.getElementById("UserName").ClassName="RedClass";
				document.getElementById("UserName").focus();
				return false;
			}
		}
	}

	if(document.getElementById("PassWord") != null)
	{
		if(document.getElementById("PassWord").value != '')
		{
			if(document.getElementById("PassWord").value.length < 6)
			{
				document.getElementById("PassWordError").innerHTML="<br>Please Type Your Password Greater Than 6 characters.";
				document.getElementById("PassWordError").style.display='';
				document.getElementById("PassWord").ClassName="RedClass";
				document.getElementById("PassWord").focus();
				return false;
			}
			var str =Trim(document.getElementById("PassWord").value);
			if( str=='')
			{
				document.getElementById("PassWordError").innerHTML="<br>Please Dont Give Space In Password Field.";
				document.getElementById("PassWordError").style.display='';
				document.getElementById("PassWord").ClassName="RedClass";
				document.getElementById("PassWord").value="";
				document.getElementById("PassWord").focus();
				return false;
			}
			else
			{
				document.getElementById("PassWordError").innerHTML="";
				document.getElementById("PassWordError").style.display='none';
				document.getElementById("PassWord").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("PassWordError") != null)
			{
				document.getElementById("PassWordError").innerHTML="<br>Please Type Your Password.";
				document.getElementById("PassWordError").style.display='';
				document.getElementById("PassWord").ClassName="RedClass";
				document.getElementById("PassWord").focus();
				return false;
			}
		}
	}

	if(document.getElementById("RPassWord") != null)
	{
		if(document.getElementById("RPassWord").value != '')
		{
			if(document.getElementById("RPassWord").value != document.getElementById("PassWord").value )
			{
				document.getElementById("RPassWordError").innerHTML="<br>Password Mismatch.";
				document.getElementById("RPassWordError").style.display='';
				document.getElementById("RPassWord").ClassName="RedClass";
				document.getElementById("RPassWord").focus();
				return false;
			}
			var str =Trim(document.getElementById("RPassWord").value);
			if( str=='')
			{
				document.getElementById("RPassWordError").innerHTML="<br>Please Dont Give Space In Retype Password Field.";
				document.getElementById("RPassWordError").style.display='';
				document.getElementById("RPassWord").ClassName="RedClass";
				document.getElementById("RPassWord").value="";
				document.getElementById("RPassWord").focus();
				return false;
			}
			else
			{
				document.getElementById("RPassWordError").innerHTML="";
				document.getElementById("RPassWordError").style.display='none';
				document.getElementById("RPassWord").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("RPassWordError") != null)
			{
				document.getElementById("RPassWordError").innerHTML="<br>Please Retype Your Password.";
				document.getElementById("RPassWordError").style.display='';
				document.getElementById("RPassWord").ClassName="RedClass";
				document.getElementById("RPassWord").focus();
				return false;
			}
		}
	}

	if(document.getElementById("FirstName") != null)
	{
		if(document.getElementById("FirstName").value != '')
		{
			//alert(document.getElementById("FirstName").value)
			//alert(document.getElementById("FirstName").value.search(NameVAlidation))
			if(document.getElementById("FirstName").value.search(NameVAlidation) >= 0 )
			{
				document.getElementById("FirstNameError").innerHTML="<br>Your First Name Should Be Only Charecters.";
				document.getElementById("FirstNameError").style.display='';
				document.getElementById("FirstName").ClassName="RedClass";
				document.getElementById("FirstName").focus();
				return false;
			}
			var str =Trim(document.getElementById("FirstName").value);
			if( str=='')
			{
				document.getElementById("FirstNameError").innerHTML="<br>Please Dont Give Space In First Name Field.";
				document.getElementById("FirstNameError").style.display='';
				document.getElementById("FirstName").ClassName="RedClass";
				document.getElementById("FirstName").value="";
				document.getElementById("FirstName").focus();
				return false;
			}
			else
			{
				document.getElementById("FirstNameError").innerHTML="";
				document.getElementById("FirstNameError").style.display='none';
				document.getElementById("FirstName").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("FirstNameError") != null)
			{
				document.getElementById("FirstNameError").innerHTML="<br>Please Type Your First Name.";
				document.getElementById("FirstNameError").style.display='';
				document.getElementById("FirstName").ClassName="RedClass";
				document.getElementById("FirstName").focus();
				return false;
			}
		}
	}



	if(document.getElementById("LastName") != null)
	{
		if(document.getElementById("LastName").value != '')
		{
			if(document.getElementById("LastName").value.search(NameVAlidation) >= 0)
			{
				document.getElementById("LastNameError").innerHTML="<br>Your Last Name Should Be Only Charecters.";
				document.getElementById("LastNameError").style.display='';
				document.getElementById("LastName").ClassName="RedClass";
				document.getElementById("LastName").focus();
				return false;
			}
			var str =Trim(document.getElementById("LastName").value);
			if( str=='')
			{
				document.getElementById("LastNameError").innerHTML="<br>Please Dont Give Space In Last Name Field.";
				document.getElementById("LastNameError").style.display='';
				document.getElementById("LastName").ClassName="RedClass";
				document.getElementById("LastName").value="";
				document.getElementById("LastName").focus();
				return false;
			}
			else
			{
				document.getElementById("LastNameError").innerHTML="";
				document.getElementById("LastNameError").style.display='none';
				document.getElementById("LastName").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("LastNameError") != null)
			{
				document.getElementById("LastNameError").innerHTML="<br>Please Type Your Last Name.";
				document.getElementById("LastNameError").style.display='';
				document.getElementById("LastName").ClassName="RedClass";
				document.getElementById("LastName").focus();
				return false;
			}
		}
	}



	if(document.getElementById("EmaiL") != null)
	{
		if(document.getElementById("EmaiL").value != '')
		{
			if(!EmailVALIdation.test(document.getElementById("EmaiL").value))
			{
				document.getElementById("EmaiLError").innerHTML="<br>Invalid Email Address.";
				document.getElementById("EmaiLError").style.display='';
				document.getElementById("EmaiL").ClassName="RedClass";
				document.getElementById("EmaiL").focus();
				return false;
			}
			var str =Trim(document.getElementById("EmaiL").value);
			if( str=='')
			{
				document.getElementById("EmaiLError").innerHTML="<br>Please Dont Give Space In Email Field.";
				document.getElementById("EmaiLError").style.display='';
				document.getElementById("EmaiL").ClassName="RedClass";
				document.getElementById("EmaiL").value="";
				document.getElementById("EmaiL").focus();
				return false;
			}
			else
			{
				document.getElementById("EmaiLError").innerHTML="";
				document.getElementById("EmaiLError").style.display='none';
				document.getElementById("EmaiL").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("EmaiLError") != null)
			{
				document.getElementById("EmaiLError").innerHTML="<br>Please Type Your Email.";
				document.getElementById("EmaiLError").style.display='';
				document.getElementById("EmaiL").ClassName="RedClass";
				document.getElementById("EmaiL").focus();
				return false;
			}
		}
	}








	if(document.getElementById("MOBIle") != null)
	{
		if(document.getElementById("MOBIle").value != '')
		{
			if(document.getElementById("MOBIle").value.search(PhonEVAlidation) >= 0)
			{
				document.getElementById("MOBIleError").innerHTML="<br>Invalid  Phone Number.";
				document.getElementById("MOBIleError").style.display='';
				document.getElementById("MOBIle").ClassName="RedClass";
				document.getElementById("MOBIle").focus();
				return false;
			}
			var str =Trim(document.getElementById("MOBIle").value);
			if( str=='')
			{
				document.getElementById("MOBIleError").innerHTML="<br>Please Dont Give Space In  Phone Field.";
				document.getElementById("MOBIleError").style.display='';
				document.getElementById("MOBIle").ClassName="RedClass";
				document.getElementById("MOBIle").value="";
				document.getElementById("MOBIle").focus();
				return false;
			}
			else
			{
				document.getElementById("MOBIleError").innerHTML="";
				document.getElementById("MOBIleError").style.display='none';
				document.getElementById("MOBIle").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("MOBIleError") != null)
			{
				document.getElementById("MOBIleError").innerHTML="<br>Please Type Your  Phone Number.";
				document.getElementById("MOBIleError").style.display='';
				document.getElementById("MOBIle").ClassName="RedClass";
				document.getElementById("MOBIle").focus();
				return false;
			}
		}
	}

	if(document.getElementById("CompName") != null)
	{
		if(document.getElementById("CompName").value != '')
		{
			//alert(document.getElementById("CompName").value)
			//alert(document.getElementById("CompName").value.search(NameVAlidation))
			if(document.getElementById("CompName").value.search(NameVAlidation) >= 0 )
			{
				document.getElementById("CompNameError").innerHTML="<br>Your Company Name Should Be Only Charecters.";
				document.getElementById("CompNameError").style.display='';
				document.getElementById("CompName").ClassName="RedClass";
				document.getElementById("CompName").focus();
				return false;
			}
			var str =Trim(document.getElementById("CompName").value);
			if( str=='')
			{
				document.getElementById("CompNameError").innerHTML="<br>Please Dont Give Space In Company Name Field.";
				document.getElementById("CompNameError").style.display='';
				document.getElementById("CompName").ClassName="RedClass";
				document.getElementById("CompName").value="";
				document.getElementById("CompName").focus();
				return false;
			}
			else
			{
				document.getElementById("CompNameError").innerHTML="";
				document.getElementById("CompNameError").style.display='none';
				document.getElementById("CompName").ClassName="NormalClass";		
			}
		}
		else
		{
			if(document.getElementById("CompNameError") != null)
			{
				document.getElementById("CompNameError").innerHTML="<br>Please Type Your Company Name.";
				document.getElementById("CompNameError").style.display='';
				document.getElementById("CompName").ClassName="RedClass";
				document.getElementById("CompName").focus();
				return false;
			}
		}
	}
var abc=document.getElementById("terms").checked;

	if(abc!='1')
	{
		document.getElementById("termsError").innerHTML="<br> You must accept the Terms and Condition to proceed.";
		document.getElementById("termsError").style.display='';
		document.getElementById("terms").ClassName="RedClass";
		return false;
	}


return true;
	

}


